package com.xiaofen.license.controller;

import com.xiaofen.license.service.VerifyLicense;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.awt.SunHints;

/**
 * 验证许可文件
 *
 * @author zhang
 * @createDate: 2021/1/22 11:14
 * @version:1.0
 * @updateUser:[修改人]
 * @updateDate:[修改时间]
 * @updateRemark:[修改备注]
 */
@RestController
public class VerifyLicenseController{
    /**
     * 获取日志打印实例
     * */
    private Logger logger = LoggerFactory.getLogger(getClass());
    /**
     * 验证许可
     * */
    @Autowired
    private VerifyLicense VerifyLicense;

    @RequestMapping(value = "/verifyLic")
    public void verifyLic(){
        try {
            if(!VerifyLicense.verify()){
                logger.info("License authorization check failed!");
                //停止服务
                System.exit(0);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
